#pragma once

#include "Comodities.h"
#include "../EntityManager.h"
#include "../Utility.h"

/*
	The bpManager may need the ability to map string hashes of output names to the indexes of the blueprints.
*/
class BlueprintManager
{
private:
	struct InstanceData
	{
		uint32 size;
		uint32 capacity;
		void* buffer;

		uint32* blueprint_id;
		uint32* comodity_hash;
		uint32* comodity_index;
		float* rate;			// for tools this is the % of breaking per run?

		InstanceData();
	};

	struct BlueprintData
	{
		uint32 size;
		uint32 capacity;
		void* buffer;

		uint32* input_start;
		uint32* input_size;
		uint32* output_start;
		uint32* output_size;
		uint32* tool_index;

		BlueprintData();
	};

private:
	InstanceData _input_data;
	InstanceData _output_data;
	// _tool_data

	BlueprintData _blueprint_data; // single output only so blueprint idx matches up with output idx

	OpenVector<uint32> hash_vector;

	// map a resource hash to the blueprint index that outputs it.
	OpenMap<uint32, uint32> _map;

	void AllocateInput(const uint32 set_capacity);
	void AllocateOutput(const uint32 set_capacity);
	void AllocateBlueprint(const uint32 set_capacity);

public:
	BlueprintManager();
	~BlueprintManager();

	const OpenVector<uint32>& Initialize();

	void GetBlueprintInput(const uint32 output_hash, uint32& input_start, uint32& input_count, float const* input_rates, uint32 const* input_indexes) const;
	void GetBlueprintOutput(const uint32 output_hash, uint32& output_start, uint32& output_count, float const* output_rates, uint32 const* output_indexes) const;
	//void GetBlueprintTool();
};